/*
ID: icerupt1
PROG: schlnet
LANG: C++11
*/

/* solution
 *
 * good.
 * 简单的联通性的图论题。
 * 先跑tarjan缩点，对于第一问就是入度为零的点的个数。
 * 第二问可以很明显的构造一下。答案就是入度为零的点的个数与出度为零的点的个数的最大值。
 * 要注意只有一个连通块的情况。
 * 
*/
#include <fstream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>

std::ifstream fin {"schlnet.in" };
std::ofstream fout{"schlnet.out"};

struct node
{
	int index, lowlink, color;
	bool on_stack, visited;
};

int n, index, color/*strong connected compoent index*/;

using edge_type = std::vector<int>;
std::vector<edge_type> graph;
std::vector<node> nodes;
std::stack<int> s;
std::vector<int> out_dgree;
std::vector<int> in_dgree;

void tarjan(int v)
{
	nodes[v].index = nodes[v].lowlink = ++index;
	nodes[v].visited = nodes[v].on_stack = true;
	s.push(v);

	for (auto it = graph[v].begin(); it != graph[v].end(); ++it) {
		int w = *it;
		if (!nodes[w].visited) {
			tarjan(w);
			nodes[v].lowlink = std::min(nodes[v].lowlink, nodes[w].lowlink);
		} else
		if (nodes[w].on_stack)
			nodes[v].lowlink = std::min(nodes[v].lowlink, nodes[w].index);
	}

	if (nodes[v].lowlink == nodes[v].index) {
		int w; color++;
		do {
			w = s.top(); s.pop();
			nodes[w].on_stack = false;
			nodes[w].color = color;
		} while (w != v);
	}

}

int main()
{
	fin >> n;
	graph.resize(n);
	nodes.resize(n);
	for (int i = 0, x; i < n; i++)
		while (fin >> x && x) graph[i].push_back(--x);

	for (int i = 0; i < n; i++)
		if (!nodes[i].visited) tarjan(i);

	out_dgree.resize(color + 1);
	in_dgree.resize(color + 1);

	for (int i = 0; i < n; i++)
		for (auto j : graph[i]) {
			if (nodes[i].color != nodes[j].color) {
				out_dgree[nodes[i].color]++;
				in_dgree[nodes[j].color]++;
			}
		}

	int zero_out = 0, zero_in = 0;
	if (color > 1)
		for (int i = 1; i <= color; i++) {
			if (!out_dgree[i]) zero_out++;
			if (!in_dgree[i]) zero_in++;
		}
	if (!zero_in) zero_in = 1;
	int ans_add_edge = std::max(zero_out, zero_in);
	if (color == 1) ans_add_edge = 0;

	std::cout << zero_in << '\n' << ans_add_edge << '\n';
	fout << zero_in << '\n' << ans_add_edge << '\n';
}

